package com.cms.web.servlet;

import com.cms.pojo.Course;
import com.cms.service.CourseService;

import javax.servlet.*;
import javax.servlet.http.*;
import javax.servlet.annotation.*;
import java.io.IOException;
import java.util.List;

@WebServlet("/writeScoreServlet")
public class WriteScoreServlet extends HttpServlet {
    private CourseService courseService = new CourseService();
    @Override
    protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
        // id
        int s_id = Integer.parseInt(request.getParameter("s_id"));
        int c_id = Integer.parseInt(request.getParameter("c_id"));
        double score = Double.parseDouble(request.getParameter("score"));

        courseService.writeScore(s_id, c_id, score);

        request.getRequestDispatcher("/courseStudentServlet").forward(request, response);
    }

    @Override
    protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
        this.doGet(request, response);
    }
}
